
package com.stu.utils;

import java.io.Serializable;

public class SendMailBean implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String smtp;//协议
	private String from;//发件者账号
	private String to;//收件者账号
	private String copyto;//抄送
	private String subject;//主题
	private String content;//邮件内容
	private String username;//发送者用户名
	private String password;//发送者密码
	private String filename; //附件路径
	private String bcc;//密送账号
	
	public static final String SMTP_EXMAIL="smtp.exmail.qq.com";
	public static final String SMTP_QQ="smtp.qq.com";
	public static final String SMTP_163="smtp.163.com";
	
	public SendMailBean() {
		super();
	}
	
	/**
	 * 发送普通邮件
	 * @param to 收件者账号,多账号用逗号分隔
	 * @param subject 主题
	 * @param content 邮件内容
	 */
	public SendMailBean(String to, String subject, String content) {
		super();
		this.smtp=ResourceUtils.get("mail", "emailServer");
		this.from = ResourceUtils.get("mail","emailFrom");
		this.to = to;
		this.copyto=null;
		this.subject = subject;
		this.content = content;
		this.username = ResourceUtils.get("mail","emailName");
		this.password=ResourceUtils.get("mail","emailPwd");
		this.filename=null;
		this.bcc=null;
	}

	/**
	 * 发送带附件带抄送的邮件
	 * @param to 收件者账号,多账号用逗号分隔
	 * @param copyto 抄送者账号,多账号用逗号分隔
	 * @param subject 主题
	 * @param content 邮件内容
	 * @param filename 附件地址,多附件用逗号分隔
	 * @param bcc 密送,多账号用逗号分隔
	 */
	public SendMailBean(String to, String copyto, String subject, String content, String filename,String bcc) {
		super();
		this.smtp=ResourceUtils.get("mail","emailServer");
		this.from = ResourceUtils.get("mail","emailFrom");
		this.to = to;
		this.copyto=copyto;
		this.subject = subject;
		this.content = content;
		this.username = ResourceUtils.get("mail","emailName");
		this.password=ResourceUtils.get("mail","emailPwd");
		this.filename=filename;
		this.bcc=bcc;
	}
	
	@SuppressWarnings("unused")
	private SendMailBean createMailBean(String smtp, String from, String to, String copyto, String subject, String content, String username, String password, String filename, String bcc){
		return new SendMailBean(smtp, from, to, copyto, subject, content, username, password, filename, bcc); 
	}
	
	/**
	 * 全构造
	 * @param smtp
	 * @param from
	 * @param to
	 * @param copyto
	 * @param subject
	 * @param content
	 * @param username
	 * @param password
	 * @param filename
	 * @param bcc
	 */
	public SendMailBean(String smtp, String from, String to, String copyto, String subject, String content, String username, String password, String filename, String bcc) {
		super();
		this.smtp = smtp;
		this.from = from;
		this.to = to;
		this.copyto = copyto;
		this.subject = subject;
		this.content = content;
		this.username = username;
		this.password = password;
		this.filename = filename;
		this.bcc = bcc;
	}


	public String getSmtp() {
		return smtp;
	}
	public void setSmtp(String smtp) {
		this.smtp = smtp;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getCopyto() {
		return copyto;
	}
	public void setCopyto(String copyto) {
		this.copyto = copyto;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getFilename() {
		return filename;
	}
	public void setFilename(String filename) {
		this.filename = filename;
	}
	
	public String getBcc() {
		return bcc;
	}

	public void setBcc(String bcc) {
		this.bcc = bcc;
	}

	@Override
	public String toString() {
		return "SendMailBean [smtp=" + smtp + ", from=" + from + ", to=" + to + ", copyto=" + copyto + ", subject="
				+ subject + ", content=" + content + ", username=" + username + ", password=" + password + ", filename="
				+ filename + ", bcc=" + bcc + "]";
	}
	

//	public static void main(String[] args) {
//		SendMailBean mailBean=new SendMailBean("1657070465@qq.com,1305425495@qq.com", "", "d", "a", "", "1305425495@qq.com");
//		MailUtils.sendEmail(mailBean);
//	}

}
